<?php
declare (strict_types=1);
namespace app\admin\middleware;

use app\middleware\Response;
class Auth
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {

        $uid = session("uid");
        $controller = strtolower($request->controller());
        if (empty($uid) && $controller != "login") {
            return redirect('/login/index');
        }
        $request->uid = $uid;
        $request->username=session("user.username");
        return $next($request);
    }
}
